<?php

namespace App\Dao\Ad;


use App\Model\Ad\Ad;
use App\Tool\Collect;
use Hyperf\Database\Model\Builder;
use Yj\Daos\Verify;

/**
 * @var Ad
 */
class AdDao extends \Yj\Daos\BaseDaos
{
    public function DaoWhere(array $params)
    {
        return $this->getDaoQuery($params, function (Verify $verify) {
            $verify('id', function (Builder $query, $id) {
                $query->where('id', $id);
            });
        });
    }

    public function lists()
    {
        return $this->getList();
    }

    public function edit($id,Collect $data)
    {
        $adData = $this->DaoWhere(compact('id'))->first();
        $adData->fill($data->toArray());
        return $adData->save();
    }

    public function del($id)
    {
        return $this->DaoWhere(compact('id'))->delete();
    }
}